//
//  BCUserManager.swift
//  NewXueBa
//
//  Created by Shine on 2019/6/3.
//  Copyright © 2019 jmxQAQ. All rights reserved.
//

import Foundation
import UIKit

class BCUserManager: NSObject {
    
    static let shareManager = BCUserManager()
    
    var Update_Message = Variable(Bool()) //更新的检测
    var Reachability_isNet = Variable(true) //网络的检测  默认有网
    var BlueTooth_isOpen = Variable(true) //蓝牙的监控，默认打开
    
    var user_uid: String? {
        set(newValue) {
            UserDefaults.standard.set(newValue, forKey: "user_uid")
        }
        get {
            return UserDefaults.standard.object(forKey: "user_uid") as? String
        }
    }
    
    var user_phone: String? {
        set(newValue) {
            UserDefaults.standard.set(newValue, forKey: "user_phone")
            self.Update_Message.value = true
        }
        get {
            return UserDefaults.standard.object(forKey: "user_phone") as? String
        }
    }
    
    var user_pwd: String? {
        set(newValue) {
            UserDefaults.standard.set(newValue, forKey: "user_pwd")
        }
        get {
            return UserDefaults.standard.object(forKey: "user_pwd") as? String
        }
    }
    // 记录登录成功的输入密码
    var user_inputPwd: String? {
        set(newValue) {
            UserDefaults.standard.set(newValue, forKey: "user_inputPwd")
        }
        get {
            return UserDefaults.standard.object(forKey: "user_inputPwd") as? String
        }
    }
    
    var  user_name: String? {
        set(newValue) {
            UserDefaults.standard.set(newValue, forKey: "user_name")
            self.Update_Message.value = true
        }
        get {
            return UserDefaults.standard.object(forKey: "user_name") as? String
        }
    }
    
    var user_token: String? {
        set(newValue) {
            UserDefaults.standard.set(newValue, forKey: "user_token")
        }
        get {
            return UserDefaults.standard.object(forKey: "user_token") as? String
        }
    }
    
    var user_photo_url: String? {
        set(newValue) {
            UserDefaults.standard.set(newValue, forKey: "user_photo_url")
        }
        get {
            return UserDefaults.standard.object(forKey: "user_photo_url") as? String
        }
    }
    
    var user_role: String? {
        set(newValue) {
            UserDefaults.standard.set(newValue, forKey: "user_role")
        }
        get {
            return UserDefaults.standard.object(forKey: "user_role") as? String
        }
    }
    
    var isLogin : Bool? {
        set(newValue) {
            UserDefaults.standard.set(newValue, forKey: "isLogin")
        }
        get {
            let login = UserDefaults.standard.object(forKey: "isLogin") as? Bool
            return login ?? false //获取的时候给个默认值false
        }
    }
    
    
}
